package com.usermanage.Mapping;

import com.usermanage.beanParam.PermissionBean;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * Created by  on 2018/9/3
 */
@Repository("permissionMapping")
public interface PermissionMapping extends JpaRepository<PermissionBean, Integer> {
    /**
     * 根据组id查询处组下所有权限
     * @param groupId
     * @return
     */
    @Query(value = "SELECT p.id,p.level,p.parent_id,p.permission_name,p.permission_url FROM u_group_permission gp LEFT JOIN u_permission p ON gp.permission_id = p.id WHERE  gp.group_id =:groupId order by p.id desc",nativeQuery = true)
    List<Map> findPermissionListByGroupId(@Param("groupId") String groupId);
}
